package net.zoneland.knowledge.controller;

import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import net.zoneland.knowledge.model.ResponseResult;
import net.zoneland.knowledge.service.DirectTrainForPartyService;

/**
 * 党建服务直通车控制层.
 * @author chw
 */
@RestController
@RequestMapping("/directTrainForParty")
public class DirectTrainForPartyController extends AbstractBaseController {
    /**
     * 日志.
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(DirectTrainForPartyController.class);

    /**
     * 党建服务直通车业务接口.
     */
    @Autowired
    private DirectTrainForPartyService directTrainForPartyService;

    /**
     * 查询pc端链接不为空的直通车数据.
     * @return 人员信息
     */
    @GetMapping("/queryPc")
    public ResponseResult queryPc() {
        final ResponseResult res = new ResponseResult();
        res.setData(directTrainForPartyService.searchPc());
        return res;
    }

    /**
     * 查询moa端链接不为空的直通车数据.
     * @return 人员信息
     */
    @GetMapping("/queryMoa")
    public ResponseResult queryMoa() {
        final ResponseResult res = new ResponseResult();
        res.setData(directTrainForPartyService.searchMoa());
        return res;
    }

    /**
     * 获取直通车数据likeByTitle.
     * @param title 标题
     * @return 结果
     */
    @PostMapping("/getZtcLikeByTitle")
    public ResponseResult getZtcLikeByTitle(final @RequestBody String title) {
        Preconditions.checkNotNull(title, "查询参数不能为空！");
        final ResponseResult result = new ResponseResult();
        result.setData(directTrainForPartyService.queryByTitle(title));
        return result;
    }

}
